﻿#include "devicedetaildialog.h"
#include "maindialog.h"
#include "ui_devicedetaildialog.h"

DeviceDetailDialog::DeviceDetailDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DeviceDetailDialog)
{
    ui->setupUi(this);

    //ui->label->setText((Dialog)parent-);
#if INDOOREMBED
    setWindowFlags(Qt::FramelessWindowHint);//隐藏窗口标题栏
#endif

    ui->btn_mainmenu_0->setText("");
    ui->btn_mainmenu_1->setText("");
    ui->btn_mainmenu_2->setText("");
    ui->btn_mainmenu_3->setText("");
    ui->btn_mainmenu_4->setText("");

    ui->btn_mainmenu_4->setStyleSheet(""
                "QPushButton#btn_mainmenu_4:pressed{border:none;background-image:url(images/main_menu4_down.jpg)}"
                "QPushButton#btn_mainmenu_4{border:none;background-image:url(images/main_menu4_up.jpg);}"
                );

    ui->btn_mainmenu_0->setStyleSheet(""
                "QPushButton#btn_mainmenu_0:pressed{border:none;background-image:url(images/main_menu0_down.jpg)}"
                "QPushButton#btn_mainmenu_0{border:none;background-image:url(images/main_menu0_up.jpg);}"
                );

    ui->btn_mainmenu_1->setStyleSheet(""
                "QPushButton#btn_mainmenu_1:pressed{border:none;background-image:url(images/main_menu1_down.jpg)}"
                "QPushButton#btn_mainmenu_1{border:none;background-image:url(images/main_menu1_up.jpg);}"
                );

    ui->btn_mainmenu_3->setStyleSheet(""
                "QPushButton#btn_mainmenu_3:pressed{border:none;background-image:url(images/main_menu3_down.jpg)}"
                "QPushButton#btn_mainmenu_3{border:none;background-image:url(images/main_menu3_up.jpg);}"
                );

    ui->btn_mainmenu_2->setStyleSheet(""
                "QPushButton#btn_mainmenu_2:pressed{border:none;background-image:url(images/main_menu2_down.jpg)}"
                "QPushButton#btn_mainmenu_2{border:none;background-image:url(images/main_menu2_up.jpg);}"
                );

    //ui->btn_mainmenu_anfang->setFocusPolicy(Qt::NoFocus);
    ui->pushButton_4->setStyleSheet("QPushButton#pushButton_4:focus{background-image:url(images/main_menu0_up.jpg)}"
                                    "border:none;background-image:url(images/main_menu0_up.jpg);");

}

DeviceDetailDialog::~DeviceDetailDialog()
{
    delete ui;
}

void DeviceDetailDialog::on_pushButton_clicked()
{
    this->close();
}

void DeviceDetailDialog::on_pushButton_2_clicked()
{
    Dialog *dialog = new Dialog(this);
    dialog->show();
    //ui->btn_mainmenu_anfang->setCheckable(false);
    //ui->btn_mainmenu_anfang->setChecked(false);

    //ui->pushButton_4->setCheckable(true);
    //ui->pushButton_4->setChecked(true);
    //this->resize(800, 480);
}

void DeviceDetailDialog::paintEvent(QPaintEvent *event)
{
    printf("DeviceDetailDialog paintEvent \n");    
    QPainter painter(this);
    painter.drawPixmap(0, 0, 800, 480, QPixmap("./images/main.jpg"));

    //ui->btn_mainmenu_anfang->setChecked(false);
    //ui->btn_mainmenu_anfang->setFlat(true);
}

void DeviceDetailDialog::on_btn_mainmenu_anfang_clicked()
{
    //QMessageBox::about(this, "", "");
}

void DeviceDetailDialog::on_btn_mainmenu_2_clicked()
{
    Dialog *dialog = new Dialog(this);
    dialog->setModal(true);
    //dialog->show();
    dialog->exec();
    delete dialog;
}
